package cn.tedu.mall.product.controller;
import cn.tedu.mall.common.pojo.product.dto.SkuAddNewDTO;
import cn.tedu.mall.common.pojo.product.dto.SkuUpdateFullInfoDTO;
import cn.tedu.mall.common.pojo.product.vo.SkuStandardVO;
import cn.tedu.mall.common.restful.JsonPage;
import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.product.service.ISkuService;
import cn.tedu.mall.product.constant.WebConst;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "库存管理")
@RestController
@RequestMapping("/pms/sku")
//@CrossOrigin
public class SkuController {

    @Autowired
    ISkuService  skuService;

    @ApiOperation("根据spuid属性查询")
    @RequestMapping("")
    public JsonResult<JsonPage<SkuStandardVO>> list(
            @RequestParam Long spuId,
            @RequestParam(required = false, defaultValue = "1") Integer page,
            @RequestParam(required = false, defaultValue = "5") Integer pageSize) {
        JsonPage<SkuStandardVO> jsonPage = skuService.list(spuId, page, pageSize);
        return JsonResult.ok(jsonPage);
    }

    @DeleteMapping("/{skuId}")
    @ApiOperation("根据skuid删除")
    public  JsonResult<Void>  removeById(@PathVariable  Long  skuId){
        skuService.deleteSku(skuId);
        return  JsonResult.ok();
    }

    @PostMapping("/addnew")
    @ApiOperation("新增sku")
    public  JsonResult<Void>  addsku( SkuAddNewDTO skuAddNewDTO){
        System.out.println(skuAddNewDTO);
        skuService.addNew(skuAddNewDTO);
        return JsonResult.ok();
    }



}
